<div style="height:550px;width: 100%" id="sidebar_left">
<div class="m_leftbar">
    <dl>
				<dt>
					<a  href="#">互动交流</a>
				</dt>
    </dl>
    <ul>
        <?php
        if($_SESSION['type']=='')
        {
            fs_showmsg('请先登录!','?');
        }
        else
        {
            if($_SESSION['type']=='3')
            { 
?>
         <li><a href="?do=message">发邮件</a></li>
        <li><a href="?do=inbox">已发邮件</a></li>
         <li><a href="?do=groupmail&c=already">班级邮件</a></li>
        <li><a href="?do=draft">草稿箱</a></li>
        <?php
            }
            elseif($_SESSION['type']=='2')
            {?>
        <li><a href="?do=message">发邮件</a></li>
        <li><a href="?do=groupmail">已发邮件</a></li>
        <li><a href="?do=message&c=already">收件箱</a></li>
        <li><a href="?do=inbox&c=already">已回复信息</a></li>
        <?php
            }
            else{
                fs_showmsg('您既不是学生也不是老师,不能使用该功能!','?');
            }
        }
        ?>
    </ul>
</div>
<!--<script type="text/javascript">
    CKEDITOR.replace( 'm_content',{ height : '100px', width:'600px',toolbar:'MyToolbar',fontSize_sizes:'16/16px' } );
</script>-->
<div class="m_rightbar">
    <?php
        $sql = "select * from nettteach_message where m_id=".$_GET['id'];
        $query =$db->query($sql);
        $messageinfo =$db->fetch_array($query);
        $r_sql = "select * from nettteach_reply where m_id=".$_GET['id'];
        $r_query = $db->query($r_sql);
        $replyinfo = $db->fetch_array($r_query);
    ?>
    <div class="m_title">查看邮件</div>
            <div class="messagecontent">
                <p><b>发件人:</b>&nbsp;&nbsp;<strong><?php echo fs_get_objinfo("nettteach_member", "id", $messageinfo['m_from'], "realname")?></strong>&nbsp;
        <?php if($_GET['c']!='already'){?>(<?php echo fs_get_objinfo("nettteach_member", "id", $messageinfo['m_from'], "passport")?>)<?php }else{?>老师 
                <?php 
                    $sql_member ="select * from nettteach_member where id =".$messageinfo['m_from'];
                    $result_member = $db -> query($sql_member);
                    $row_member = $db ->fetch_array($result_member);
                ?>(<?php echo fs_get_objinfo("nettteach_department", "id", $row_member['departmentid'], "name")?>/<?php echo fs_get_objinfo("nettteach_major", "id", $row_member['majorid'], "name")?>)
                <?php }?>
                </p>
                <p><b>主&nbsp;&nbsp;&nbsp;题:</b>&nbsp;&nbsp;<?php echo $messageinfo['object']?></p>
                <p><b>内&nbsp;&nbsp;&nbsp;容:</b></p>
                <div class="showcontent">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $messageinfo['content']?></div>
                <?php if($_GET['c']!='already'){?>
                    <p><b>回&nbsp;&nbsp;&nbsp;复:</b></p>
        <?php
        if($_SESSION['type']=='2'&&$replyinfo==''){  
        ?>
        <div class="replybox">
                <form action="" method="post">
                <textarea name="reply" cols="45" rows="10"></textarea><br/><br/>
                <input type="hidden" name="fromid" value="<?php echo $messageinfo['m_to']?>"/>
                <input type="hidden" name="toid" value="<?php echo $messageinfo['m_from']?>"/>
                <input type="hidden" name="mid" value="<?php echo $_GET['id'];?>"/>
                <input type="submit" name="sub" value="回复"/>
        </div>          
        <?php        
         }
         else{
             ?>
        <div class="replycontent">
            
            <?php
            
            if($replyinfo){
            ?>
<!--            <p>(<?php echo date('Y-m-d H:i:s',$replyinfo['replytime']);?>)回复内容:</p>-->
<!--            <p class="r_content"><?php echo $replyinfo['content'];?></p>-->
            <div class="showcontent">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $replyinfo['content']?></div>
        <?php
            }
            else{
                ?>
        <div class="showcontent">&nbsp;&nbsp;&nbsp;&nbsp;暂无回复</div>

        <?php
            }?> </div>
                <?php
         }
                }
             ?>           
    </div>
</div>
</div>
<?php
if($_POST['sub'])
{
    $mid = $_POST['mid'];
    $r_from = $_POST['fromid'];
    $r_to = $_POST['toid'];
    $content = $_POST['reply'];
    $sql = "insert into nettteach_reply (`m_id`,`content`,`replytime`,`r_from`,`r_to`) values(".$_POST['mid'].",'".$content."',".time().",".$r_from.",".$r_to.")";
    $query = $db->query($sql);
    if($query)
    {
        $up_sql = "update nettteach_message set is_read=1 where m_id=".$mid;
        $db->query($up_sql);
        fs_showmsg('回复成功!');
    }
}
?>
